const { validationResult } = require('express-validator');

const validator = (validations) => {
    return async (req, res, next) => {
        for (const validation of validations) {
            await validation.run(req);
        }
        const result = validationResult(req)
        if(!result.isEmpty()){
            res.status(400).json({ errors1: result.array() })
        }else{
            next()
        }
       
    }
}

module.exports = validator
